//
//  ViewController.m
//  多组数据
//
//  Created by song on 15/1/10.
//  Copyright (c) 2015年 song. All rights reserved.
//

#import "ViewController.h"

@interface ViewController () <UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.tableView.dataSource = self;
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"numberof RowsInSection  %d", section);
    if(section ==0)
    {
        return 2;
    }else
    {
        return 2;
    }
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    
    
    if(indexPath.section ==0 )
    {
        if(indexPath.row ==0)
        {
            cell.textLabel.text =@"奥迪";
        }else if(indexPath.row == 1)
        {
            cell.textLabel.text =@"宝马";
        }
        
    }else if(indexPath.section == 1)
    {
        if(indexPath.row==0)
        {
            cell.textLabel.text =@"本田";
        }else if(indexPath.row ==1)
        {
            cell.textLabel.text =@"丰田";
        }
    }
    return cell;
    
}

-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
    if(section == 0)
    {
        return @"德系品牌";
    }else
    {
        return @"日韩品牌";
    }
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if(section == 0)
    {
        return @"德系品牌";
    }else
    {
        return @"日韩品牌";
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
